
NUI Chapter 4. A Motion-tracking Missile Launcher

From the website:

  Killer Game Programming in Java
  http://fivedots.coe.psu.ac.th/~ad/jg

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the website.

Thanks,
  Andrew

============================

This directory contains 5 Java files:
  * MotionLauncher.java, MLPanel.java,
    JCVMotionDetector.java, JMFCapture.java,      
    MissileLauncher.java


There is 1 image file, used by the application:
  * crosshairs.png


There is 1 subdirectory:
  * libusbjava Examples\    -- holds three small libusbjava examples;
                               see the readme.txt in that directory
                               for details

There are 2 batch files:
  * compile.bat
  * run.bat
     - make sure they refer to the correct locations for your
       downloads of JMF, JavaCV, OpenCV, and libusbjava


----------------------------
Before Compilation/Execution:

You need to download and install:
   * JMF: http://java.sun.com/products/java-media/jmf/
          I downloaded the JMF Performance Pack for Windows v.2.1.1e 
          and installed it in C:\Program Files\JMF2.1.1e
 
   * OpenCV: http://opencv.willowgarage.com/
             I downloaded v2.2 for Windows with pre-compiled binaries:
                OpenCV-2.2.0-win32-vs2010.exe
             and installed it in C:\OpenCV2.2

   * JavaCV: http://code.google.com/p/javacv/
             I downloaded javacv-bin-20110219.zip 
                      and javacv-src-20110219.zip
              --> I unzipped the 'bin' file and installed it in C:\javacv-bin
              --> I unzipped the 'src' file so I could search the source code
                  and generate Java docs

   * libusb-win32: http://sourceforge.net/apps/trac/libusb-win32/wiki
             I downloaded libusb-win32-bin-1.2.4.0.zip
             --> The executable installs libusb-win32 into c:\Program Files\LibUSB-Win32\
             --> copy and rename the relevant DLLs in bin\ over to the OS
                   e.g. libusb0_x86.dll --> Windows\system32\libusb0.dll 
                        libusb0.sys --> Windows\systems32\drivers\libusb0.sys

   * libusbjava: http://libusbjava.sourceforge.net/wp/
             I downloaded ch.ntb.usb-0.5.9.jar and LibusbJava_dll_0.2.4.0.zip
             --> move the JAR and unzipped DLL to c:\LibUsbJava



----------------------------
Other requirements:

  * obtain a Dream Cheeky MSN Missile Launcher
       - Dream Cheeky no longer sells the MSN launcher, which was replaced by the
         Storm O.I.C. (Over Internet Control) in 2010 (http://www.dreamcheeky.com/storm-oic-missile-launcher)

       - you can still find the MSN launcher at third-party resellers and eBay

       - the MSN software is still available at Dream Cheeky, at
         http://www.dreamcheeky.com/piano/pianomanual.html


  * plug the Launcher and its webcam into two USB ports

  * Create a libusb-win32 device driver for the launcher using libusb-win32's
    inf-wizard.exe

  * Obtain some USB analysis tools:
       - USBDeview (free from http://www.nirsoft.net/utils/usb_devices_view.html) 
       - USBTrace (free 15 day trial from http://www.sysnucleus.com/)
      

----------------------------
Compilation:

> compile *.java
    // you must have JMF, JavaCV, OpenCV, libusb-win32, libusbjava installed

----------------------------
Execution:

> run MotionLauncher
    // you must have JMF, JavaCV, OpenCV, libusb-win32, libusbjava installed;
    // you must have installed a libusb driver for the launcher
    // you must have plugged in the launcher 
    // OpenCV can take several seconds to start up

The launcher's webcam must be registered with "JMF Registry"
before MotionLauncher will see it. You'll find the application below 
the JMF menu item in Windows.  

Check the device name using "JMF Registry", and update the 
CAP_DEVICE string in JMFCapture.java accordingly. Currently it
has the value: "vfw:Microsoft WDM Image Capture (Win32):0",
which is a commonly used name in WinXP.

On my test machine, it sometimes takes 5 seconds for the first
picture to appear, but only 10-20ms for each subsequent one.

The application 'freezes' for a few seconds when the application's
close box is pressed, to wait for the JMF link to be completely
shut down.

----------------------------
Last updated: 31st May 2011
